//index.js
//获取应用实例
var app = getApp()
Page({
  data: {
    circledetail:
    {
      circletype:'circle',
      userimg:'/static/img/2.jpg',
      username:'抽抽',
      addtime:'2019/09/23',
      circletitle:'糖醋排骨',
      circledes:' 最好要寸排，骨头越细的那种越好，说明猪岁数比较小，肉嫩，而且小骨头不压分量;2.处理好排骨，买小寸排最好，这次我用的',
      circleimg:[{imgurl:'https://f11.baidu.com/it/u=2646093511,2820815036&fm=72'},{imgurl:'https://f10.baidu.com/it/u=1856966395,724479572&fm=72'}],
      subnum:1,
      viewnum:2,
      zan:1,
      like:false,
      zanstate:false},
      circlecomment:[{
          cid:1,
          cmuser:'https://f11.baidu.com/it/u=2646093511,2820815036&fm=72',
          cmusername:'抽抽',
          commenttime:'5天前',
          commentct:"很赞的早餐"
      },
      {
          cid:2,
          cmuser:'https://f11.baidu.com/it/u=2646093511,2820815036&fm=72',
          cmusername:'抽抽',
          commenttime:'3天前',
          commentct:"肯定很好吃"
      }]
    },
    zan:function(e){
    let state=this.data.circledetail.zanstate
    let zannum=this.data.circledetail.zan
    if(state===false){
    this.setData({
        zanstate:true,
        zan:zannum+1
    })
    }else{
      this.setData({
        zanstate:false,
        zan:zannum-1
      })
      }
  },
  collection:function(e){
    let currentIndex =e.currentTarget.dataset.id-1
    let state=this.data.circledetail[currentIndex].like
    if(state===false){
      this.setData({
        ['circledetail['+currentIndex+'].like']:true
      })
    }else{
      this.setData({
        ['circledetail['+currentIndex+'].like']:false
      })
    }
    
  },
    })